<template>
  <d2-container>
      <el-select v-model="value" placeholder="请选择" style="margin-top:10px;">
        <el-option
          v-for="item in options"
          :key="item.id"
          :label="item.admin"
          :value="item.id">
        </el-option>
      </el-select>
      <el-date-picker
        v-model="value1"
        type="daterange"
        range-separator="至"
        style="margin-left:10px;"
        value-format="yyyy-MM-dd HH:mm:ss"
        start-placeholder="开始日期"
        end-placeholder="结束日期">
      </el-date-picker>
      <el-button type="primary" @click="merchantconsumptions()" style="margin-left:10px;">查询</el-button>
      <el-table
        :data="tableData"
        border
        style="width: 100%;margin-top:20px;">
        <el-table-column
          prop="id"
          label="序号"
          width="80">
        </el-table-column>
        <el-table-column
          prop="user"
          label="商家 名称"
          width="120">
        </el-table-column>
        <el-table-column
          prop="cooperation_message"
          label="消费详情"
          width="700">
        </el-table-column>
        <el-table-column
          prop="cooperationlog_time"
          label="记录时间">
        </el-table-column>
        <el-table-column
          prop="cooperation_money"
          label="商家消费前余额">
        </el-table-column>
      </el-table>
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="page"
        :page-size="10"
        layout="total, prev, pager, next"
        :total="Number(count)">
      </el-pagination>
  </d2-container>
</template>

<script>
    import { merchantconsumption,cooperationlist } from "@/api/sys.login";
    export default {
        name: "index",
        data(){
            return{
              page:1,
              pageSize:10,
              tableData:[], //列表
              value:"",
              value1:[],
              options:[] //商家列表
            }
        },
        methods:{
          handleCurrentChange(val){
            this.page = val
            this.merchantconsumptions()
          },
          merchantconsumptions(){
            merchantconsumption(this.page,this.pageSize,this.value,this.value1[0],this.value1[1]).then((res)=>{
                 this.tableData = res.list
                 this.count = res.count
            })
          },
          cooperationshoplists(){
            cooperationlist({
              page:1,
              pageSize:100
            }).then((res)=>{
              this.options = res.data
            })
          }
        },
        created() {
            this.cooperationshoplists()
            this.merchantconsumptions()
        }
    }
</script>

<style>

</style>
